feat: add requestWith*URL utils and use for faster mounts#1342
Conversation
Lightweight request proxying via `Proxy` to override the URL without cloning the entire `Request` object. Uses a shared proxy handler with a `WeakMap` for per-proxy URL storage to minimize allocations. `requestWithBaseURL` strips a base path prefix from the request URL and is now used internally by `H3.mount()` instead of `new Request()`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis pull request introduces two new utility functions— Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
requestWithURL and requestWithBaseURLrequestWith*URL utils and use for faster mount
requestWith*URL utils and use for faster mountrequestWith*URL utils and use for faster mounts
Summary
requestWithURL(req, url)— creates a lightweightProxyover aRequestthat overrides only theurlproperty, avoidingnew Request()allocationrequestWithBaseURL(req, base)— strips a base path prefix from the request URL usingrequestWithURLProxyHandlerwith aWeakMapfor per-proxy URL storage to minimize allocationsH3.mount()now usesrequestWithBaseURLinstead ofnew Request(url, event.req)Test plan
requestWithURL(url override, method/headers preserved,instanceof Request,clone())requestWithBaseURL(base stripping, root fallback, query string preservation)mount.test.tspasses with the refactored implementation🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests